
#ifndef _IRESOURCE_H_
#define _IRESOURCE_H_

#include <BBuffer>

namespace BWE
{
	class IResource : public BBuffer
	{
	public:
		IResource();
		IResource(const BByte* bytes, int size);
		~IResource();

		void reset(const BByte* bytes, int size);
		virtual const BByte* data() const;

		bool empty() const;
		void clear();

		bool begin() const;
		bool end() const;

		virtual IOMode mode() const override;

		virtual bool seek(int offset) const override;
		virtual bool wseek(int offset) override;

		virtual int offset() const override;
		virtual int size() const override;

		virtual bool read(void* data, int size) const override;
		virtual bool write(const void* data, int size) override;

		virtual bool read(BString& text) const override;
		virtual bool write(const BString& text) override;

		virtual bool readCStr(char* cstr, int size) const override;
		virtual bool writeCStr(const char* cstr, int size = -1) override;

		virtual bool readLine(char* cstr, int size) const override;
		virtual bool writeLine(const char* cstr, int size = -1) override;

		virtual bool readLine(BString& line) const override;
		virtual bool writeLine(const BString& line) override;

		using BStream::read;
		using BStream::write;

	private:
		IOMode			_mode;
		const BByte*	_bytes;
		int				_size;
		mutable int		_offset;
	};
}

#endif
